//
//  ViewController.m
//  XIBProje
//
//  Created by meitianhui2 on 2017/11/29.
//  Copyright © 2017年 DeLongYang. All rights reserved.
/*
    对于 xib 中Object 等的使用整体的代码结构不够清晰 ，不利于维护。
    尤其是一些复杂的界面。
 */

#import "ViewController.h"
#import "IBSlider.h"   // xib's  Slider
#import "PropertySubClassOne.h"   // propertySubClassOne

@interface ViewController ()

// 我们通过IB 来
@property (weak, nonatomic) IBOutlet IBSlider *slider;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    //
    PropertySubClassOne *subClassOne = self.slider.subClassOne;
//    subClassOne.delegate = self;
    
    [subClassOne setValueProvider:^(float *value) {
        *value = [_slider value];
        NSLog(@"block get value is:%f",*value);
    }];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark ---- 一个有趣的测试
// 我们设置xib 中的object 的代理为 ViewController 测试 是否能行
- (void)propertySubClassOneDidUpdateValue:(float *)value
{
    *value = [_slider value];
     NSLog(@"delegate  get value %f",*value);
}

#pragma mark ---- UISlider Value Change
//
- (IBAction)onSliderValueChange:(id)sender
{
    IBSlider *slider = (IBSlider *)sender;
    [[slider subClassOne] execute];
}









@end
